package com.britoso.morerecent;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.util.Log;

/**
 * Show Recent Tasks, this activity is needed because the Dialog needs a parent.
 * @author britoso
 *
 */
public class RecentActivity extends Activity
{
	private RecentData appData;
	final boolean DEBUG = false;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		long start = System.currentTimeMillis();
		appData = ((RecentData) getApplication());// get cached data from prev runs
		appData.init(DEBUG);

		// Debug.startMethodTracing("morerecent");//write trace data to /sdcard/morerecent.trace
		RecentDialog myDialog = new RecentDialog(this, appData, DEBUG);
		myDialog.setOnDismissListener(new DialogDismissListener());
		myDialog.show();
		Log.i(RecentActivity.class.getName(), "onCreate() took " + (System.currentTimeMillis() - start));
	}

	private class DialogDismissListener implements OnDismissListener
	{
		@Override
		public void onDismiss(DialogInterface arg0)
		{
			// Log.i(RecentDialog.class.getName(), "Dismissing.");
			finish();
			// Debug.stopMethodTracing();
		}
	}
}